# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file '获取单击的工具栏按钮.ui'
##
## Created by: Qt User Interface Compiler version 5.15.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2 import QtCore, QtWidgets, QtGui
from PySide2.QtWidgets import QMessageBox
import sys


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        MainWindow.setCentralWidget(self.centralwidget)

        # 创建工具栏
        self.toolBar = QtWidgets.QToolBar(MainWindow)
        self.toolBar.setObjectName("toolBar")
        self.toolBar.setMovable(True)
        self.toolBar.setOrientation(QtCore.Qt.Horizontal)
        # 设置工具栏中按钮的显示方式为：文字显示在图标下方
        self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        # 为工具栏添加QAction
        self.toolBar.addAction(QtGui.QIcon("新建.ico"), "新建")

        # 创建“打开”按钮对象
        self.open = QtWidgets.QAction(QtGui.QIcon("打开.ico"), "打开")

        # 创建“关闭”按钮对象
        self.close = QtWidgets.QAction(QtGui.QIcon("关闭.ico"), "关闭")
        self.toolBar.addActions([self.open, self.close])   # 将创建的两个QAction添加到工具栏中

        # 创建一个combox下拉列表控件
        self.combobox = QtWidgets.QComboBox()
        # 定义职位立列表
        list = ["总经理", "副总经理", "人事部经理", "财务部经理", "部门经理", "普通员工"]
        self.combobox.addItems(list)
        self.toolBar.addWidget(self.combobox)    # 在工具栏中添加 combobox组件
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)

        # 将combobox组件的选项更改信号与自定义槽函数关联
        self.combobox.currentIndexChanged.connect(self.showinfo)

        # 为菜单中的QAction绑定triggered信号
        self.toolBar.actionTriggered[QtWidgets.QAction].connect(self.getvalue)

        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 800, 26))
        MainWindow.setMenuBar(self.menubar)

        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"\u83b7\u53d6\u5355\u51fb\u7684\u5de5\u5177\u680f\u6309\u94ae", None))
    # retranslateUi
    # 定义菜单的QAction的触发槽函数
    def getvalue(self, m):
        QMessageBox.information(MainWindow, "提示", "您选择的是：" + m.text(), QMessageBox.Ok)

    def showinfo(self):
        QMessageBox.information(MainWindow, "提示", "您选择的职位是：" + self.combobox.currentText(), QMessageBox.Ok)


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
